<!doctype HTML>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>

<div style="user-select: none; -moz-user-select: none">
<span id="foo">foo</span><span id="bar" style="user-select: text; -moz-user-select: text">bar</span>
</div>

<script>
test(function() {
  assert_not_equals(window.eventSender, undefined, 'This test requires window.eventSender');

  let selection = window.getSelection();
  function moveAndDoubleClick(element) {
    eventSender.mouseMoveTo(element.offsetLeft + element.offsetWidth / 2, element.offsetTop + element.offsetHeight / 2);
    eventSender.mouseDown();
    eventSender.mouseUp();
    eventSender.leapForward(1);
    eventSender.mouseDown();
    eventSender.mouseUp();
    eventSender.leapForward(1);
  }

  // 'foo' cannot be selected.
  moveAndDoubleClick(foo);
  assert_equals(selection.toString(), '', 'selection.toString');

  // 'bar' can be selected even though its parent cannot be selected.
  moveAndDoubleClick(bar);
  assert_equals(selection.toString(), 'bar', 'selection.toString');
});
</script>

